package com.film;

import com.film.utils.MySqlConnection;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;


import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;


@SpringBootApplication
public class BackendApplication {

    public static void main(String[] args) throws SQLException {
        SpringApplication.run(BackendApplication.class, args);
        //创建数据库链接
        MySqlConnection.connection();

        //测试数据库
        Statement stmt = MySqlConnection.connect.createStatement(); //创建执行sql语句的对象
        String sql = "select * from User";
        ResultSet result = stmt.executeQuery(sql);
        while(result.next()){
            String id = result.getString("id") ;
            String username = result.getString("username") ;
            System.out.println("id: " + id + " username: " + username);
        }
        result.close();
        stmt.close();
    }

}
